<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div id="add_question">
    <form:form id="addQuestionForm" action="questions/add" method="post" commandName="question">
        <form:label path="text">Text:</form:label>
        <br/>
        <form:textarea path="text" rows="5"/>
        <br/>
        <form:errors path="text"/>
        <br/>
        <form:label path="responseType">Response type:</form:label>
        <br/>
        <form:radiobutton path="responseType" value="SINGLE"/>Single
        <br/>
        <form:radiobutton path="responseType" value="MULTIPLE"/>Multiple choice
        <br/>
        <form:errors path="responseType"/>
        <br/>
        <c:if test="${errorMessage != null}">
            <span class="error"><fmt:message key="${errorMessage}"/></span>
            <br/>
        </c:if>
        <label>Number of responses:</label>
        <select id="noOfResponses" name="noOfResponses" onchange="showRows();">
            <option value="2">2</option>
            <option value="3" selected="true">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
        </select>
        <br/>

        <div id="responseContainer">
            <c:forEach items="${question.responses}" var="response" varStatus="index">
                <form:textarea path='responses[${index.count - 1}].text' class=''/>
                <form:errors path='responses[${index.count - 1}].text'/>
                <br/>
            </c:forEach>
        </div>

        <a href="#" class="underline_2" onclick="submitQuestion();">Save question</a>
    </form:form>
</div>